﻿App.Views.Index = function () {

    var self = this;

    var TerminalModel = function(name)
    {
        this.terminal = ko.observable(name);
        this.idTerminal =  ko.computed(function() {
           var obj = _.findWhere(App.Cache.terminalesList(), {Descripcion: this.terminal() });
           return (_.isEmpty(obj) == false) ? obj.IdParada : 0; 
       }, this);

    };

    self.avalibleTerminales = ko.observableArray([]);
    self.origen = new TerminalModel("");
    self.destino = new TerminalModel("");
    self.pasajeros = ko.observable();
    self.fechaIda = ko.observable();
    self.fechaVuelta = ko.observable();
    self.IsOneWay  = ko.observable(1);


    self.buscarPasajes = function (e) {
        return true;
    };


    App.Views.Index.prototype.init = function () {

        App.Common.Aux.typeAheadTerminalesInit(["txtOrigenTerminal", "txtDestinoTerminal"]);
        App.Common.Aux.dpickerInit({id: "dpickerSalida", validateWith: "dpickerVuelta" });

        $('#myCarousel').carousel({
            interval: 1000
        });

    };

};

